package com.dyz.swordFingerOffer;

/**
 * @author: daiyizheng
 * @date: 2021/6/2 14:12
 * @description:
 */
public class FindFirstCommonNode52 {
    public ListNode FindFirstCommonNode(ListNode pHead1, ListNode pHead2) {
        if(pHead1==null ||pHead2==null){
            return null;
        }
        ListNode cur1 = pHead1;

        while (cur1!=null){
            ListNode cur2 = pHead2;
            while(cur2!=null){
                if(cur2.val==cur1.val){
                    return cur2;
                }
                cur2 = cur2.next;
            }
            cur1 = cur1.next;
        }
        return null;

    }
}
